package com.fxkj.cloud.drms.domain.alarm;

import lombok.Getter;

import java.util.UUID;

/**
 * <p>description: 报警历史记录</p>
 * @author ww
 * @date 2025/4/7 13:24
 */
@Getter
public class AlarmHistoryDomain {
    private UUID id;
    private String deviceSerialNo;
    private String deviceName;
    private Long startTs;
    private Long endTs;
    private Boolean closed;
    private String alarmText;
    private Integer alarmLevel;
    private String alarmCode;
    private String alarmValue;
    private UUID deviceId;
    private UUID productId;
    private UUID organizationId;
    private String alarmName;

    public AlarmHistoryDomain(UUID id, String deviceSerialNo, String deviceName, Long startTs, Long endTs,
                              Boolean closed, String alarmText, Integer alarmLevel, String alarmCode,
                              String alarmValue, UUID deviceId, UUID productId, UUID organizationId,String alarmName) {
        this.id = id;
        this.deviceSerialNo = deviceSerialNo;
        this.deviceName = deviceName;
        this.startTs = startTs;
        this.endTs = endTs;
        this.closed = closed;
        this.alarmText = alarmText;
        this.alarmLevel = alarmLevel;
        this.alarmCode = alarmCode;
        this.alarmValue = alarmValue;
        this.deviceId = deviceId;
        this.productId = productId;
        this.organizationId = organizationId;
        this.alarmName = alarmName;
    }

    public static AlarmHistoryDomain create(String deviceSerialNo, String deviceName, Long startTs, Long endTs,
                                            Boolean closed, String alarmText, Integer alarmLevel, String alarmCode,
                                            String alarmValue, UUID deviceId, UUID productId, UUID organizationId,String alarmName) {
        return new AlarmHistoryDomain(null, deviceSerialNo, deviceName, startTs, endTs, closed, alarmText,
                alarmLevel, alarmCode, alarmValue, deviceId, productId, organizationId,alarmName);
    }

    public void close(long closeTs, String text) {
        this.endTs = closeTs;
        this.closed = true;
        this.alarmText = text;
    }
}
